package com.micro.client;

import org.springframework.stereotype.Component;
import java.math.BigDecimal;

@Component
public class UserServiceClientFallback implements UserServiceClient {
    
    @Override
    public UserDTO getUserByUsername(String username) {
        // 降级处理：返回默认用户信息
        UserDTO userDTO = new UserDTO();
        userDTO.setUserId(0L);
        userDTO.setUsername(username);
        userDTO.setEmail("fallback@example.com");
        userDTO.setPhone("00000000000");
        userDTO.setBalance(BigDecimal.ZERO);
        return userDTO;
    }
    
    @Override
    public UserDTO getUserById(Long userId) {
        // 降级处理：返回默认用户信息
        UserDTO userDTO = new UserDTO();
        userDTO.setUserId(userId);
        userDTO.setUsername("unknown");
        userDTO.setEmail("fallback@example.com");
        userDTO.setPhone("00000000000");
        userDTO.setBalance(BigDecimal.ZERO);
        return userDTO;
    }

    @Override
    public boolean consume(Long userId, BigDecimal amount) {
        // 降级处理：消费失败
        return false;
    }

    @Override
    public boolean recharge(String username, BigDecimal amount) {
        // 降级处理：充值失败
        return false;
    }
    
    @Override
    public PassengerDTO getPassengerByIdCard(String idCardNumber) {
        // 降级处理：返回默认乘客信息
        PassengerDTO passengerDTO = new PassengerDTO();
        passengerDTO.setPassengerId(1L);
        passengerDTO.setUserId(1L);
        passengerDTO.setPassengerName("默认乘客");
        passengerDTO.setIdCardNumber(idCardNumber);
        passengerDTO.setPassengerType(0);
        passengerDTO.setGender(1);
        passengerDTO.setActive(true);
        return passengerDTO;
    }
}
